<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index9</title>
  <style type="text/css">
            div {
 
                font-weight:bold;    
                font-family: Microsoft Yahei;
                width: 400px;
                padding-left: 50px;
                margin-left: 450px;
            }
 
            h1 {
                text-align: center;
            }
 
        </style>
  
</head>
<script>
function sort(){
    var num = new Array(4,2,5,6,3,1);
    var i,j,temp;
    for(i=0;i<num.length;i++){
        for(j=i+1;j<num.length;j++){
            if(num[i]<num[j]){
                temp = num[j];
                num[j] = num[i];
                num[i] = temp;
            }
        }
    }
    var sort = document.getElementById('sort');
    sort.innerHTML = '['+num+']';
}

</script>
<body>
    <br>
    <br>
<center>
    <div id="sort">[4,2,5,6,3,1]</div>
    <br>
    <input type="button" value="点我排序" onclick="sort()">
</center>
</body>

</html>